﻿-- =============================================
-- Author:		顾世杰
-- Create date: <Create Date,,>
-- Description:	变更 表 中公司ID
-- =============================================
CREATE PROCEDURE [dbo].[UpdateCompanyID]
	(
	@Old_Companyid int,
	@new_Companyid int
	)
AS
BEGIN

--修改支出
update Finance_Outlay set companyidcur=@new_Companyid where companyidcur=@Old_Companyid
--收入
update Finance_RunningAccount set companyid=@new_Companyid where companyid=@Old_Companyid
--收入临时表
update Finance_RunningAccountCopy set  companyid=@new_Companyid where companyid=@Old_Companyid
--报销
update L_Reimbursement set companyid=@new_Companyid where companyid=@Old_Companyid
--报销中资产列表
update L_Reimbursement_Assets set companyid=@new_Companyid where companyid=@Old_Companyid
--借款 
update Loan set  companyid=@new_Companyid where companyid=@Old_Companyid
--公司往来
update L_Dealings set I_CompanyId=@new_Companyid where  I_CompanyId=@Old_Companyid
update L_Dealings set O_CompanyId=@new_Companyid where  O_CompanyId=@Old_Companyid
--成单 
update [Order] set companyid=@new_Companyid where companyid=@Old_Companyid
--成单项
update Order_Item set CompanyId=@new_Companyid where companyid=@Old_Companyid
--项目分析
update Project set CompanyId=@new_Companyid where companyid=@Old_Companyid
update Project set MoveCompanyId=@new_Companyid where MoveCompanyId=@Old_Companyid
--变更
update Order_Change_Hedge set CompanyId=@new_Companyid where companyid=@Old_Companyid
--任务	
update Project_Task set CompanyId=@new_Companyid where companyid=@Old_Companyid
--银行
update Finance_Bank set CompanyId=@new_Companyid where companyid=@Old_Companyid	
--账目平整
update Finance_Balance set CompanyId=@new_Companyid where companyid=@Old_Companyid	
--摊销
update ConsumableMonth set 	CompanyIdcur=@new_Companyid where companyidcur=@Old_Companyid		
--客户表	
update Customer set 	CompanyId=@new_Companyid where companyid=@Old_Companyid	
--首款尾款
update [Order_PaymentRecord] set CompanyId=@new_Companyid where companyid=@Old_Companyid	
--提现存现
update [txcx] set  CompanyId=@new_Companyid where companyid=@Old_Companyid	
--资产
update Assets set  CompanyId=@new_Companyid where companyid=@Old_Companyid	
END
